/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.project.model;

/**
 *
 * @author DoHongPhuc
 */
public class SqlSyntax {

    private StringBuffer sb = new StringBuffer();

    public SqlSyntax select(String sql) {
        sb.append("SELECT (" + sql + ") ");
        return this;
    }

    public SqlSyntax from(String sql) {
        sb.append("FROM (" + sql + ") ");
        return this;
    }

    public SqlSyntax where(String sql) {
        sb.append("WHERE (" + sql + ") ");
        return this;
    }
    public SqlSyntax append(String sql) {
        sb.append("(" + sql + ") ");
        return this;
    }

    public SqlSyntax insert(String sql){
        sb.append("INSERT INTO " + sql);
        return this;
    }

    public SqlSyntax values(String sql){
        sb.append(" VALUES (" + sql + ")");
        return this;
    }

    @Override
    public String toString() {
        return sb.toString();
    }

    public static void main(String[] args) {
        SqlSyntax sqlSyntax = new SqlSyntax();
        sqlSyntax.select("id, name, age");
        sqlSyntax.from("student");
        sqlSyntax.where("name LIKE %phuc%");
        System.out.println(sqlSyntax.toString());
    }
}
